import {actionTypes} from './index'
import http from "@/http";
import {message} from 'antd'
export const changeLoginStatus = (value)=>({
    type: actionTypes.CHANG_LOGIN_STATUS,
    value
});

export const login = (values)=>{
   return (dispatch)=>{
       http.ajax({
           url: '/login/userLogin',
           method: 'post',
           params: {
               userName: values.username,
               password: values.password
           },
           showLoading: false
       }).then((res) => {
           if (res.status === 1) {
               localStorage.setItem('loginStatus', 'true')
               dispatch(changeLoginStatus(true))
               message.info('登录成功跳转中...');
           } else {
               message.error('用户名或者密码错误!')
           }
       }).catch(() => {
           message.error('用户名或者密码错误!')
       })
   }
};

export const disableButton = () =>({
    type: actionTypes.DISABLE_BUTTON
})


